<?php
/**
 * 账户信息
 * User: tengyu
 * Date: 2017/8/28
 * Time: 16:54
 */?>
@extends('common.common')
@section('title','账户-个人中心')
@section('css')<link rel="stylesheet" href="{{asset('/css/personal_account.css')}}">@endsection
@section('js')
    <script>
        //消费分页页码记录
        function consume_page(page)
        {
            var consume_page = $("input[name='consume_page']").val();
            $.ajax({
                url:'/user/account/consume',
                type:'post',
                headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' },
                dataType:'json',
                data:{'consume_page':consume_page,'page':page},
                success:function(res)
                {
                    if(res.msg=='查询分页成功'){
                        var da = eval(res.data);
                        var html='';
                        html+='<input type="hidden" name="consume_page" value="'+res.account_consume['consume_page']+'">';
                        html+=' <ul class="list-inline accountInfo"><li>商品名称</li><li>单价</li><li>数量</li><li>时长</li></ul>';
                        for(var i=0;i<da.length;i++){
                            html+='<ul class="list-inline accountInfotwo">';
                            html+='<li class="imgInfo"><div class="media"><div class="media-left">';
                            html+='<img src="'+res.account_consume['file_path']+da[i].fitment_details_imgMaster+'"style="border-radius:20px;height: 92px;width: 151px;">';
                            html+='</div><div class="media-body"><p>'+da[i].fitments_name+'</p><p>';
                            html+='<img src="'+res.account_consume['color'][da[i].color_type]+'">';
                            html+='</p></div></div></li><li class="otherdetails">¥';
                            if(da[i].details_rent_type==1){
                                html+=da[i].details_nimbleprice;
                            }else{
                                html+=da[i].details_fixprice;
                            }
                            html+='/月</li>';
                            html+='<li class="otherdetails">'+da[i].details_fitment_number+'</li>';
                            html+=' <li class="otherdetails">';
                            if(da[i].details_rent_type==1){
                                html+='12个月';
                            }else{
                                html+='18个月';
                            }
                            html+='</li>';
                            html+='</ul>';
                        }
                        html+='<div class="col-xs-12 text-right">';
                        html+='<a href="javascript:void(0)" onclick="consume_page('+"'"+res.account_consume['page_action']['0']+"'"+')">首页</a>';
                        html+='<a href="javascript:void(0)" onclick="consume_page('+"'"+res.account_consume['page_action']['1']+"'"+')">上一页</a>';
                        html+='<a href="javascript:void(0)" onclick="consume_page('+"'"+res.account_consume['page_action']['2']+"'"+')">下一页</a>';
                        html+='<a href="javascript:void(0)" onclick="consume_page('+"'"+res.account_consume['page_action']['3']+"'"+')">尾页</a><br />';
                        html+='</div>';
                        $("#account_consume_list").html(html);
                    }else {
                        alert(res.msg);
                    }
                },
                error:function(){
                    alert('请求失败!');
                }
            });
        }
        //账单分页页码记录
        function bill_page(page)
        {
            var bill_page = $("input[name='bill_page']").val();
            $.ajax({
                url:'/user/account/bill',
                type:'post',
                headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' },
                dataType:'json',
                data:{'bill_page':bill_page,'page':page},
                success:function(res)
                {
                    if(res.res=='查询分页成功'){
                        var bill = eval(res.data);
                        var html='';
                        html+='<input type="hidden" name="bill_page" value="'+res.account_bill['bill_page']+'">';
                        html+='';
                        for(var i=0;i<bill.length;i++){
                            html+='<ul class="list-inline accountInfotwo">';
                            html+='<li class="imgInfo"><div class="media"><div class="media-left">';
                            html+='<img src="'+res.account_bill['file_path']+bill[i].fitment_details_imgMaster+'"style="border-radius:20px;height: 92px;width: 151px;">';
                            html+='</div><div class="media-body"><p>'+bill[i].fitments_name+'</p><p>';
                            html+='<img src="'+res.account_bill['color'][bill[i].color_type]+'">';
                            html+='</p></div></div></li><li class="otherdetails">¥';
                            if(bill[i].rent_type==1){
                                html+=bill[i].details_nimbleprice;
                            }else{
                                html+=bill[i].details_fixprice;
                            }
                            html+='/月</li>';
                            html+='<li class="otherdetails">'+bill[i].num+'</li>';
                            html+=' <li class="otherdetails">';
                            if(bill[i].rent_type==1){
                                html+='12个月';
                            }else{
                                html+='18个月';
                            }
                            html+='</li>';
                            html+='</ul>';
                        }
                        html+='<div class="col-xs-12 text-right">';
                        html+='<a href="javascript:void(0)" onclick="bill_page('+"'"+res.account_bill['page_action']['0']+"'"+')">首页</a>';
                        html+='<a href="javascript:void(0)" onclick="bill_page('+"'"+res.account_bill['page_action']['1']+"'"+')">上一页</a>';
                        html+='<a href="javascript:void(0)" onclick="bill_page('+"'"+res.account_bill['page_action']['2']+"'"+')">下一页</a>';
                        html+='<a href="javascript:void(0)" onclick="bill_page('+"'"+res.account_bill['page_action']['3']+"'"+')">尾页</a><br />';
                        html+='</div>';
                        $("#account_bill_list").html(html);
                    }else{
                        alert(res.msg);
                    }
                },
                error:function(){
                    alert('查询账单数据失败');
                }
            });
        }
    </script>
@endsection
@section('content')
    <div id="content">
        <!--内容导航栏-->
        @include('common.centernav')
        <div class="container">
            <div class="row">
            @include('usercenter.usersidebar')
                <!--2、右侧主体-->
                <div class="col-xs-9">
                    <!--右侧面版-->
                    <div class="panel panel-default rightPanel">
                        <div class="panel-heading">
                            <h4>账户信息</h4>
                        </div>
                        <div class="panel-body bodyone">
                            账户余额：<span>{{$param['user_account']->account}}</span>&nbsp;元
                            <button class="btn btn-warning pull-right tixian" onclick="alert('待研发')">提现</button>
                            <button class="btn btn-warning pull-right "><a href="{{url('/user/recharge')}}" style="color:#ffffff;">充值</a></button>
                        </div>
                        <div class="panel-heading">
                            <h4>消费记录</h4>
                        </div>
                        <div class="panel-body bodytwo" id="account_consume_list">
                            <input type="hidden" name="consume_page" value="{{$param['consume_page']}}">
                            <ul class="list-inline accountInfo">
                                <li>商品名称</li>
                                <li>单价</li>
                                <li>数量</li>
                                <li>时长</li>
                            </ul>
                            @if($param['account_rent']['res_count'][0]->num>0)
                            @foreach($param['account_rent']['res_page'] as $v)
                            <ul class="list-inline accountInfotwo">
                                <li class="imgInfo">
                                <div class="media">
                                    <div class="media-left"><img src="{{asset(env('STATIC_FILE_ERP_PATH').$v->fitment_details_imgMaster)}}" style="border-radius:20px;height: 92px;width: 151px;"></div>
                                    <div class="media-body">
                                        <p>{{$v->fitments_name}}</p>
                                        <p><img src="{{$param['color'][$v->color_type]}}"></p>
                                    </div>
                                </div>
                                </li>
                                <li class="otherdetails">¥ @if($v->details_rent_type==1){{$v->details_nimbleprice}}@else{{$v->details_fixprice}}@endif/月</li>
                                <li class="otherdetails">{{$v->details_fitment_number}}</li>
                                <li class="otherdetails"> @if($v->details_rent_type==1){{'12个月'}}@else{{'18个月'}}@endif</li>
                            </ul>
                            @endforeach
                            <div class="col-xs-12 text-right">
                                <a href="javascript:void(0)" onclick="consume_page('first')">首页</a>
                                <a href="javascript:void(0)" onclick="consume_page('prev')">上一页</a>
                                <a href="javascript:void(0)" onclick="consume_page('next')">下一页</a>
                                <a href="javascript:void(0)" onclick="consume_page('last')">尾页</a><br />
                            </div>
                            @else
                            <div class="text-center"> <img src="{{asset('/img/771509094256_.pic.jpg')}}" alt="暂无数据"></div>
                            @endif
                        </div>
                        <div class="things">
                            <img src="{{asset('/img/zaizujiaju.jpg')}}">
                            在租家具：<span>{{$param['account_rent']['res_count'][0]->num}}</span>&nbsp;组
                            {{--<img src="{{asset('/img/youhuiquan.jpg')}}" class="coupnImg">
                            可用优惠券：<span>1</span>&nbsp;张--}}
                        </div>
                        <div class="panel-heading">
                            <h4>应付账单</h4>
                        </div>
                        <div class="panel-body bodytwo" id="account_bill_list">
                            <input type="hidden" name="bill_page" value="{{$param['bill_page']}}">
                            @if($param['account_bill']['res_count'][0]->num>0)
                            @foreach($param['account_bill']['res_page'] as $key=>$value)
                            <ul class="list-inline accountInfotwo">
                                <li class="imgInfo">
                                <div class="media">
                                    <div class="media-left">
                                        <img src="{{asset(env('STATIC_FILE_ERP_PATH').$value->fitment_details_imgMaster)}}" style="border-radius:20px;height: 92px;width: 151px;">
                                    </div>
                                    <div class="media-body">
                                        <p>{{$value->fitments_name}}</p>
                                        <p><img src="{{$param['color'][$value->color_type]}}"></p>
                                    </div>
                                </div>
                                </li>
                                <li class="otherdetails">¥{{$value->price}}/月</li>
                                <li class="otherdetails">{{$value->num}}</li>
                                <li class="otherdetails">@if($value->rent_type==1){{'12个月'}}@else{{'18个月'}} @endif</li>
                            </ul>
                            @endforeach
                            <div class="col-xs-12 text-right">
                                <a href="javascript:void(0)" onclick="bill_page('first')">首页</a>
                                <a href="javascript:void(0)" onclick="bill_page('prev')">上一页</a>
                                <a href="javascript:void(0)" onclick="bill_page('next')">下一页</a>
                                <a href="javascript:void(0)" onclick="bill_page('last')">尾页</a><br />
                            </div>
                            @else
                            <div class="text-center"> <img src="{{asset('/img/771509094256_.pic.jpg')}}" alt="暂无数据"></div>
                            @endif
                        </div>
                        <div class="extra">
                            当前额度：<span>@if($param['user_quota']){{$param['user_quota']->quota_current}}@else{{'0'}}@endif</span>&nbsp;元
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
